import * as Base64 from 'crypto-js/enc-base64';
import * as Utf8 from 'crypto-js/enc-utf8';
// import { Logger } from '@nestjs/common';

/**
 * @author 加密工具类
 * 获取IP地址
 */
export class CryptoJS {
  /**
   * @desc base64编码
   * @param
   * @return
   */
  static encodeBase64(rawStr: string) {
    const wordArray = Utf8.parse(rawStr);
    const base64 = Base64.stringify(wordArray);
    return base64;
  }

  /**
   * @desc base64解码
   * @param
   * @return
   */
  static decodeBase64(base64: string) {
    const parsedWordArray = Base64.parse(base64);
    const parsedStr = parsedWordArray.toString(Utf8);
    return parsedStr;
  }
}
